#include<bits/stdc++.h>
using namespace std;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	
	freopen("replace.in", "r", stdin);
	freopen("replace.out", "w", stdout);
	
	int n, m;
	cin >> n >> m;
	while(n--){
		string s;
		string ss;
		cin >> s;
		cin >> ss;
	}
	while(m--){
		string s;
		string ss;
		cin >> s;
		cin >> ss;
		
		cout << "0" << "\n";
	}
	
	return 0;
}
/*

4 4 2
1 4 6
2 3 7
4 2 5
4 3 4
1 1 8 2 4
100 1 3 2 4

*/
